package org.hjj.design.u95.viewer;

import org.hjj.design.u95.EmailSender;
import org.hjj.design.u95.domain.RequestStat;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * email implementation of {@link StatViewer}
 *
 * @author:何嘉俊
 * @date:2021/5/18
 */
public class EmailViewer implements StatViewer {

    private EmailSender emailSender;
    private List<String> toAddresses = new ArrayList<>();

    public EmailViewer() {
        this.emailSender = new EmailSender(/*省略参数*/);
    }

    public EmailViewer(List<String> addresses) {
        toAddresses.addAll(addresses);
        this.emailSender = new EmailSender(/*省略参数*/);
    }

    public EmailViewer(List<String> addresses, EmailSender emailSender) {
        toAddresses.addAll(addresses);
        this.emailSender = emailSender;
    }

    public void addToAddress(String address) {
        toAddresses.add(address);
    }

    @Override
    public void output(Map<String, RequestStat> requestStats, long startTimeInMillis, long endTimeInMillis) {
        // format the requestStats to HTML style.
        // send it to email toAddresses.
    }
}
